package com.ruoyi.legal.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.legal.domain.RecordDetailsView;
import com.ruoyi.legal.service.IRecordDetailsViewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * detailController
 * 
 * @author xiaoxiao
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/legal/detail")
public class RecordDetailsViewController extends BaseController
{
    @Autowired
    private IRecordDetailsViewService recordDetailsViewService;

    /**
     * 查询detail列表
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecordDetailsView recordDetailsView)
    {
        startPage();
        List<RecordDetailsView> list = recordDetailsViewService.selectRecordDetailsViewList(recordDetailsView);
        return getDataTable(list);
    }

    /**
     * 导出detail列表
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:export')")
    @Log(title = "detail", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RecordDetailsView recordDetailsView)
    {
        List<RecordDetailsView> list = recordDetailsViewService.selectRecordDetailsViewList(recordDetailsView);
        ExcelUtil<RecordDetailsView> util = new ExcelUtil<RecordDetailsView>(RecordDetailsView.class);
        util.exportExcel(response, list, "detail数据");
    }

    /**
     * 获取detail详细信息
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(recordDetailsViewService.selectRecordDetailsViewById(id));
    }

    /**
     * 新增detail
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:add')")
    @Log(title = "detail", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordDetailsView recordDetailsView)
    {
        return toAjax(recordDetailsViewService.insertRecordDetailsView(recordDetailsView));
    }

    /**
     * 修改detail
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:edit')")
    @Log(title = "detail", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordDetailsView recordDetailsView)
    {
        return toAjax(recordDetailsViewService.updateRecordDetailsView(recordDetailsView));
    }

    /**
     * 删除detail
     */
    @PreAuthorize("@ss.hasPermi('legal:detail:remove')")
    @Log(title = "detail", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recordDetailsViewService.deleteRecordDetailsViewByIds(ids));
    }
}
